var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var i in t) t.hasOwnProperty(i) && (e[i] = t[i]);
    })(e, t);
}, function(e, t) {
    function i() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (i.prototype = t.prototype, 
    new i());
}), a = this && this.__decorate || function(e, t, i, n) {
    var o, s = arguments.length, r = s < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, i) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, i, n); else for (var a = e.length - 1; 0 <= a; a--) (o = e[a]) && (r = (s < 3 ? o(r) : 3 < s ? o(t, i, r) : o(t, i)) || r);
    return 3 < s && r && Object.defineProperty(t, i, r), r;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("GameData"), s = e("LoadManager"), c = e("Global"), l = cc._decorator, d = l.ccclass, u = l.property, p = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.border = null, e.right = null, e.scoreLabel = null, e.nameLabel = null, 
        e.score = 0, e.sprite = null, e.skeleton = null, e.spriteUrl = "", e.skeletonUrl = "", 
        e;
    }
    return i(e, t), e.prototype.start = function() {}, e.prototype.init = function(t) {
        if (null != t.type) switch (t.type) {
          case c.RewardType.SKIN:
            var e;
            this.adjust(0), this.sprite && (this.sprite.node.active = !1), null != t.idx && (this.appendSkeleton({
                url: "skin/" + t.idx + "/skeleton",
                pos: cc.v2(0, 30),
                animation: "animation2"
            }), 0 < (e = c.G.personModelList.filter(function(e) {
                return e.id == t.idx;
            })).length && (this.nameLabel.string = e[0].m));
            break;

          case c.RewardType.ELF:
            this.adjust(1), this.sprite && (this.sprite.node.active = !1), null != t.idx && (this.appendSkeleton({
                url: "skin/p" + t.idx + "/xiaojingling",
                pos: cc.v2(0, -30),
                animation: "move2"
            }), this.nameLabel.string = "小精灵");
            break;

          case c.RewardType.ARM:
            this.adjust(0), this.skeleton && (this.skeleton.node.active = !1), null != t.idx && (3e3 <= t.idx ? (this.appendSprite({
                url: "texture/armOlympic/" + t.idx,
                pos: cc.v2(0, 80)
            }), t.idx - 3e3 < c.G.olympicGunModelList.length && (this.nameLabel.string = c.G.olympicGunModelList[t.idx - 3e3].m)) : 2e3 <= t.idx ? (this.appendSprite({
                url: "image/arm_draw/" + c.G.getDrawIdx(t.idx),
                pos: cc.v2(0, 80)
            }), t.idx - 2e3 < c.G.drawGunModelList.length && (this.nameLabel.string = c.G.drawGunModelList[t.idx - 2e3].m)) : 1e3 <= t.idx || t.idx < 0 ? (this.appendSprite({
                url: "image/arm3/" + c.G.getEggIdx(t.idx),
                pos: cc.v2(0, 80)
            }), t.idx - 1e3 < c.G.eggGunModelList.length && (this.nameLabel.string = c.G.eggGunModelList[t.idx - 1e3].m)) : (this.appendSprite({
                url: "image/arm/" + t.idx,
                pos: cc.v2(0, 80)
            }), t.idx < c.G.gunModelList.length && (this.nameLabel.string = c.G.gunModelList[t.idx].m)));
            break;

          case c.RewardType.BOX:
            this.adjust(1), this.skeleton && (this.skeleton.node.active = !1), this.appendSprite({
                url: "image/ui/宝箱",
                pos: cc.v2(0, 60)
            }), this.nameLabel.string = "巅峰宝箱";
        }
        null != t.score && (this.score = t.score, r.GD.curScore >= this.score ? this.right.active = !0 : this.right.active = !1, 
        this.scoreLabel.string = t.score.toString());
    }, e.prototype.adjust = function(e) {
        switch (e) {
          case 0:
            this.border.scale = 1, this.right.setPosition(cc.v2(80, 20)), this.nameLabel.node.y = 0, 
            this.nameLabel.fontSize = 30;
            break;

          case 1:
            this.border.scale = .8, this.right.setPosition(cc.v2(65, 15)), this.nameLabel.node.y = -10, 
            this.nameLabel.fontSize = 25;
        }
    }, e.prototype.appendSprite = function(e) {
        e.url && (this.sprite || (this.sprite = new cc.Node().addComponent(cc.Sprite), this.sprite.node.parent = this.node), 
        this.sprite.node.active = !0, e.url != this.spriteUrl && (e.pos && this.sprite.node.setPosition(e.pos), 
        this.spriteUrl = e.url, s.default.getInstance().loadSpriteFrame({
            url: e.url,
            sprite: this.sprite
        })));
    }, e.prototype.appendSkeleton = function(t) {
		
        var i = this;
        t.url && (this.skeleton || (this.skeleton = new cc.Node().addComponent(sp.Skeleton), 
        this.skeleton.node.parent = this.node), this.skeleton.node.active = !0, t.url != this.skeletonUrl && (t.pos && this.skeleton.node.setPosition(t.pos), 
        this.skeletonUrl = t.url, s.default.getInstance().loadRes({
            url: t.url,
            type: sp.SkeletonData
        }).then(function(e) {
            i.skeleton.skeletonData = e, t.animation && i.skeleton.setAnimation(0, t.animation, !0);
        })));
    }, a([ u(cc.Node) ], e.prototype, "border", void 0), a([ u(cc.Node) ], e.prototype, "right", void 0), 
    a([ u(cc.Label) ], e.prototype, "scoreLabel", void 0), a([ u(cc.Label) ], e.prototype, "nameLabel", void 0), 
    a([ d ], e);
}(cc.Component);

n.default = p;